package com.spring.service.lmpl;

import com.spring.dao.AccountDao;
import com.spring.service.AccountService;
import com.spring.utils.TansformThing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServicelmpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Autowired
    private TansformThing tansformThing;

    @Override
    public void TransFormMoney(String outUser, String inUser, Double money) {
        try{
//            开启事务
            tansformThing.BeginThing();
            accountDao.out(outUser,money);
            accountDao.in(inUser,money);
//            提交事务
            tansformThing.commit();
        }catch (Exception e){
            System.out.println(e);
            tansformThing.rollBack();

        }finally {
            tansformThing.releas();
        }
    }
}
